package com.hisan.freeride.home.adapter;

/**
 * 创建时间 : 2017/11/16
 * 创建人：yangyingqi
 * 公司：嘉善和盛网络有限公司
 * 备注：无
 */

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

public abstract class CommonAdapter<T> extends BaseAdapter {
    protected Context context;
    protected List<T> listBeans;
    protected int layoutId;

    public CommonAdapter(Context context, List<T> listBeans, int layoutId) {
        this.context = context;
        this.listBeans = listBeans;
        this.layoutId = layoutId;
    }

    public int getCount() {
        return this.listBeans.size();
    }

    public T getItem(int position) {
        return this.listBeans.get(position);
    }

    public long getItemId(int position) {
        return (long)position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = ViewHolder.getHolder(this.context, convertView, position, this.layoutId);
        this.convert(holder, this.getItem(position));
        return holder.getConvertView();
    }

    public abstract void convert(ViewHolder var1, T var2);
}
